package cn.duwey.scs.common.dto;

import cn.duwey.scs.common.constants.PageConstants;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
public class PageResult<T> {

    private int currentPage;

    private int totalPage;

    private int pageSize = PageConstants.DEFAULT_PAGE_SIZE;

    private int totalCount;

    List<T> records;

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        this.totalPage = this.totalCount % this.pageSize == 0 ? (this.totalCount / this.pageSize) :
                (this.totalCount / this.pageSize + 1);
    }
}
